<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细目录</title>
    <#include "../common/link.ftl"/>
    <script>
        $(function () {
            //回显数据
            $(".btn-input").click(function () {
                var json = $(this).data("json");

                    $("input").val("");
                $("#iddd").val('${(dic.id)!}');
                $("#a123").val('${(dic.title)!}');
                if (json) {
                    $("input[name='id']").val(json.id);
                    $("input[name='title']").val(json.title);
                    $("input[name='sequence']").val(json.sequence);
                }

                $('#myModal').modal('show');
            })

            //提交表单
            $(".btn-primary").click(function () {
                $.messager.confirm("温馨提示", "确认保存吗", function () {
                    $("#editForm").ajaxSubmit(function (data) {
                        if (data.success) {
                            $.messager.popup("保存成功,两秒后跳转页面")
                            setTimeout(function () {
                                window.location.reload();
                            }, 2000)
                        } else {
                            $.messager.popup(data.msg);
                        }
                    })
                })
            })
            //删除操作
            $(".btn-delete").click(function () {
                var url = $(this).data("url");
                $.messager.confirm("温馨提示", "确定要删除吗", function () {
                    $.get(url, function (data) {
                        if (data.success) {
                            $.messager.popup("删除成功,2秒后跳转页面");
                            setTimeout(function () {
                                window.location.reload();
                            }, 2000)
                        } else {
                            $.messager.popup(data.msg);
                        }
                    })
                })
            })

        })
    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<#include "../common/navbar.ftl" />
    <!--菜单回显-->
<#assign currentMenu="systemDictionaryItem"/>
<#include "../common/menu.ftl" />
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典明细管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/systemDictionaryItem/list" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                <#--//点击目录查询时,反翻页数据丢失 添加隐藏域设置parentId的值-->
                    <input type="hidden" name="parentId" value="${(qo.parentId)!}">
                </form>

                <br>
                <div class="row">

                    <div class="  col-sm-3">
                        <div class="panel panel-info">
                            <div class="panel-heading"><strong>字典明细</strong></div>
                            <ul class="list-group" id="dicDirUl">
                                <#list dics as d>
                                <li class="list-group-item">
                                    <a class="dicDir" data-pid="${(d.id)!}"
                                       href="/systemDictionaryItem/list?parentId=${d.id}">${d.title}</a>
                                </li>
                                </#list>
                                <script>
                                    $(".dicDir[data-pid='${qo.parentId}']").closest("li").addClass("active");
                                    $(".dicDir[data-pid='${qo.parentId}']").css("color", "white")
                                </SCRIPT>
                            </ul>
                        </div>
                    </div>
                <#if (pageInfo.list)??>


                    <div class="col-sm-9">
                        <a href="javaScript:;" class="btn btn-success btn-input" style="margin: 10px">
                            <span class="glyphicon glyphicon-plus"></span> 添加明细
                        </a>
                        <!--编写内容-->
                        <div class="box-body table-responsive no-padding ">
                            <table class="table table-hover table-bordered" align="center">
                                <tr>
                                    <th>编号</th>
                                    <th>标题</th>
                                    <th>序号</th>
                                    <th>操作</th>
                                </tr>
                            <#list pageInfo.list as sys>
                            <tr>
                                <td>${sys_index+1}</td>
                                <td>${(sys.title)!}</td>
                                <td>${(sys.sequence)!}</td>
                                <td>
                                    <a href="javaScript:;" data-json='${sys.json}'
                                       class="btn btn-info btn-xs btn-input">
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                    <a href="#" data-url="/systemDictionaryItem/delete?deptId=${sys.id}"
                                       class="btn btn-danger btn-xs btn_delete">
                                        <span class="glyphicon glyphicon-trash"></span> 删除
                                    </a>
                                </td>
                            </tr>
                            </#list>

                            </table>
                            <!--分页-->
                            <#include "../common/page.ftl"/>
                        </div>
                    </div>

                </#if>
                </div>
        </section>
    </div>
    <#include "../common/footer.ftl" />
</div>
<!-- Modal -->

<div class="modal fade" id="myModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">数据字典编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate.do" method="post" id="editForm">
                    <input type="hidden" id="iddd" name="parent.id">
                    <input type="hidden"  name="id">
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">字典目录：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="a123" name="parentTitle" disabled>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label  class="col-sm-3 control-label">明细标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" value="" placeholder="请输入数据字典明细标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">明细序号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control"  name="sequence" value="" placeholder="请输入数据字典明细编号">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary btn_submit" >保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal" >取消</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>
